package logic

import (
	"context"
	"gitee.com/Cauchy_AQ/vxopen/rpc/transform/transformer"

	"gitee.com/Cauchy_AQ/vxopen/api/internal/svc"
	"gitee.com/Cauchy_AQ/vxopen/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type RegisterLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewRegisterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RegisterLogic {
	return &RegisterLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *RegisterLogic) Register(req *types.UserOptReq) (resp *types.UserOptResp, err error) {
	_, err = l.svcCtx.Transformer.Register(l.ctx, &transformer.UserOptReq{
		Mobile: req.Mobile,
		Passwd: req.Passwd,
		Key:    req.Key,
		Code:   req.Code,
	})
	if err != nil {
		return nil, err
	}
	return &types.UserOptResp{}, nil
}
